#include <string.h>
#include <stddef.h>

#define MIN(a,b)   ((a)<(b)?(a):(b))

size_t strnlen(const char *s, size_t maxlen)
{
    size_t len = strlen(s);
    return MIN(maxlen,len);
}
